<style>
.modal_sys_changepass{ }
.modal_sys_changepassbox{ padding:10px;}
.modal_sys_changepassbox p{ margin:0 0 10px 0;}

.modal_sys_msgbox{ padding:15px;}
.modal_sys_msgboxbody{ height:400px; overflow-y:scroll}
</style>
<div class="modal_sys_changepass" style="display:none">
  <div class="modal_sys_changepassbox">
  	<form id="modal_sys_changepassform" onsubmit="return false;">
  	<p><input type="password" name="opass" required lay-verify="required" placeholder="请输入旧密码" autocomplete="off" class="layui-input"/></p>
    <p><input type="password" name="newpass" required lay-verify="required" placeholder="请输入新的密码" autocomplete="off" class="layui-input"/></p>
    <p><input type="password" name="newpass2" required lay-verify="required" placeholder="请再次输入新的密码" autocomplete="off" class="layui-input"/></p>
    </form>
  </div>
</div>


<div class="modal_sys_msg" style="display:none">
  <div class="modal_sys_msgbox">
  <div class="modal_sys_msgboxbody">
  	<ul class="layui-timeline">
      
    </ul>
    </div>
  </div>
</div>
<script>
function funSys_changepass(){
	layer.open({
		type: 1,
		title:"修改密码",
		area:"400px",
		skin: 'layui-layer-rim',
		content:$(".modal_sys_changepass").show(),
		btn:['修改','关闭'],
		btn1:function(index,layero){
			if(!$("input[name='opass']").val().length){
				layer.msg("请输入旧密码",{icon:2,time:1500});
				return;
			}
			if(!$("input[name='newpass']").val().length){
				layer.msg("请输入新的密码",{icon:2,time:1500});
				return;
			}
			if($("input[name='newpass']").val()!=$("input[name='newpass2']").val()){
				layer.msg("两次输入的密码不一样",{icon:2,time:1500});
				return;
			}
			if($("input[name='newpass']").val().length<6){
				layer.msg("密码不能少于6位",{icon:2,time:1500});
				return;
			}
			var data={
				"opass":$("input[name='opass']").val(),
				"newpass":$("input[name='newpass']").val(),
			};
			var index2=layer.load(1, {shade: [0.1,'#fff']});
			$.post("{php echo $this->createMobileUrl('index',array('op'=>'changepassword'))}",data,function(returnstr){
				layer.close(index2);
				var result=eval("("+returnstr+")");
				if(!result.success){
					layer.msg(result.msg,{icon:2,time:1500});
					return;
				}
				layer.msg("密码修改成功",{icon:2,time:1500},function(){
					layer.close(index);
				});
			});
		},
		success: function(layero, index){
			$("#modal_sys_changepassform")[0].reset();
		},
		end:function(){
			$(".modal_sys_changepass").hide();
		}
	});
}
function funSys_help(){
	var helplink="{php echo $cfg['helplink']}";
	if(!helplink)return ;
	var _height=$(window).height()-30;
	var _width=$(window).width()-30;
	layer.open({
	  type: 2,
	  title:0,
	  shadeClose: true,
	  shade: 0.8,
	  area: [_width+'px', _height+'px'],
	  content: helplink
	}); 
}
function funSys_message(){
	layer.open({
		type: 1,
		title:0,
		area:"400px",
		skin: 'layui-layer-rim',
		content:$(".modal_sys_msg").show(),
		success: function(layero, index){
			var index2=layer.load(1, {shade: [0.1,'#fff']});
			$.post("{php echo $this->createMobileUrl('index',array('op'=>'getmessage'))}",{},function(returnstr){
				layer.close(index2);
				console.log(returnstr);
				$("#Txt_search").val('').focus();
				var result=eval("("+returnstr+")");
				$(".modal_sys_msgboxbody ul").empty();
				if(result.success){
					var temp='';
					var list=result.list;
					for(i in list){
						temp+='<li class="layui-timeline-item"> <i class="layui-icon layui-timeline-axis">&#xe63f;</i><div class="layui-timeline-content layui-text"><h3 class="layui-timeline-title">'+list[i].time+'</h3><p>'+list[i].message+'</p></div></li>';
					}
					$(".modal_sys_msgboxbody ul").append(temp);
				}
			});
		},
		end:function(){
			$(".modal_sys_msg").hide();
		}
	});
}
</script>


<style>
    .modal_today{ }
    .modal_todaybox{padding:15px;}
    .modal_today_top{ border:1px solid #CCC; padding:10px;}
    .modal_today tr td:nth-child(2n){ text-align:right; color:#10F}
    .modal_todayboxfoot{padding:15px 0 0 0; height:50px;}
</style>
<div class="modal_today" style="display:none">
    <div class="modal_todaybox">
        <form id="modal_todayform"  class="layui-form"  onsubmit="return false;">
            <div class="modal_today_top"><span class="blue">{$shop['companyname']}</span> <span class="pull-right blue">{php echo date("Y-m-d")}</span></div>
            <div class="layui-form">
                <table class="layui-table" lay-skin="line">
                    <tr>
                        <td colspan="2"><b>今日总收益</b></td>
                        <td colspan="2" id="mdltoday_all">&nbsp;</td>
                    </tr>
                    <tr>
                        <td><b>销售总收益</b></td>
                        <td id="mdltoday_allsale">-</td>
                        <td><b>充值总收益</b></td>
                        <td id="mdltoday_charge">-</td>
                    </tr>
                    <tr>
                        <td colspan="4"><b>销售统计</b></td>
                    </tr>
                    <tr>
                        <td>订单数</td>
                        <td id="mdltoday_num1">-</td>
                        <td>销售商品</td>
                        <td id="mdltoday_num2">-</td>
                    </tr>
                    <tr>
                        <td>销售金额(含茶位)</td>
                        <td id="mdltoday_sale1">&nbsp;</td>
                        <td>优惠</td>
                        <td id="mdltoday_sale2">&nbsp;</td>
                    </tr>
                    <tr>
                        <td>茶位</td>
                        <td id="mdltoday_sale4">&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td colspan="2"><b>退款统计</b></td>
                        <td colspan="2" id="mdltoday_refundfee">&nbsp;</td>
                    </tr>
                    <tr>
                        <td>退款订单数</td>
                        <td class="mdltoday_salepay" id="mdltoday_refundorder">&nbsp;</td>
                        <td>退款商品</td>
                        <td class="mdltoday_salepay" id="mdltoday_refundgoods">&nbsp;</td>
                    </tr>
                    <tr>
                        <td colspan="2"><b>收银方式统计</b></td>
                        <td colspan="2">&nbsp;</td>
                    </tr>
                    <tr>
                        <td>微信</td>
                        <td class="mdltoday_salepay" id="mdltoday_salepay0">&nbsp;</td>
                        <td>支付宝</td>
                        <td class="mdltoday_salepay" id="mdltoday_salepay1">&nbsp;</td>
                    </tr>
                    <tr>
                        <td>现金</td>
                        <td class="mdltoday_salepay" id="mdltoday_salepay2">&nbsp;</td>
                        <td>银行卡</td>
                        <td class="mdltoday_salepay" id="mdltoday_salepay3">&nbsp;</td>
                    </tr>
                    <tr>
                        <td>余额</td>
                        <td class="mdltoday_salepay" id="mdltoday_salepay4">&nbsp;</td>
                        <td>{if $shop["custom_pay1_status"]}{$shop["custom_pay1"]}{else}-{/if}</td>
                        <td class="mdltoday_salepay" id="mdltoday_salepay5">-</td>
                    </tr>
                    <tr>
                        <td>{if $shop["custom_pay2_status"]}{$shop["custom_pay2"]}{else}-{/if}</td>
                        <td class="mdltoday_salepay" id="mdltoday_salepay6">-</td>
                        <td>{if $shop["custom_pay3_status"]}{$shop["custom_pay3"]}{else}-{/if}</td>
                        <td class="mdltoday_salepay" id="mdltoday_salepay7">-</td>
                    </tr>
                    <tr>
                        <td>{if $shop["custom_pay4_status"]}{$shop["custom_pay4"]}{else}-{/if}</td>
                        <td class="mdltoday_salepay" id="mdltoday_salepay8">&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>

                    <tr>
                        <td colspan="2"><b>充值方式统计</b></td>
                        <td colspan="2">&nbsp;</td>
                    </tr>
                    <tr>
                        <td>微信</td>
                        <td id="mdltoday_chargepay0">&nbsp;</td>
                        <td>支付宝</td>
                        <td id="mdltoday_chargepay1">&nbsp;</td>
                    </tr>
                    <tr>
                        <td>现金</td>
                        <td id="mdltoday_chargepay2">&nbsp;</td>
                        <td>银行卡</td>
                        <td id="mdltoday_chargepay3">&nbsp;</td>
                    </tr>
                    <tr>
                        <td><b>总现金</b></td>
                        <td id="mdltoday_allcash">&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
            </div>
            <div class="modal_todayboxfoot text-right">
                <button type="button" class="layui-btn layui-btn-normal modal_todaysubmit">打印</button>
                <button type="button" class="layui-btn layui-btn-primary modal_todayboxclose">关闭</button>
            </div>
        </form>
    </div>
</div>

<div class="modal_todaygoods" style="display: none;">
    <div class="modal_todaygoodsbox" style="height: 500px;overflow-y: scroll">
        <table class="layui-table">
            <thead>
            <tr>
                <th>商品名称</th>
                <th>条码</th>
                <th>单价</th>
                <th>数量</th>
                <th>原金额</th>
                <th>实收金额</th>
            </tr>
            </thead>
            <tbody>

            </tbody>
        </table>
    </div>
    <div class="modal_todayboxfoot text-right">
        <button type="button" class="layui-btn layui-btn-normal modal_todaygoodssubmit">打印</button>
        <button type="button" class="layui-btn layui-btn-primary modal_todaygoodsboxclose">关闭</button>
    </div>
</div>
<script>
    function funSys_today(){
        layer.open({
            type: 1,
            title:"今日经营情况",
            area:"700px",
            skin: 'layui-layer-rim',
            content:$(".modal_today").show(),
            success: function(layero, index){
                $(".modal_todayboxclose").on("click",function(){
                    layer.close(index);
                });
                $(".modal_todaysubmit").on("click",function(){
                    fun_print(9,0);
                });
                var index2=layer.load(1, {shade: [0.1,'#fff']});
                $.post("{php echo $this->createMobileUrl('index',array('op'=>'gettoday'))}",{},function(returnstr){
                    layer.close(index2);
                    console.log(returnstr);
                    var result=eval("("+returnstr+")");
                    if(result.success){
                        var items=result.item;
                        var refundorder=result.refundorder;
                        var refundgoods=result.refundgoods;
                        var refundlist=result.refundlist;
                        $("#mdltoday_sale1").text("￥ "+fee2num(parseInt(items.fee1)+parseInt(items.fee4)));
                        $("#mdltoday_sale2").text("￥ "+fee2num(items.fee2));
                        $("#mdltoday_allsale").text("￥ "+fee2num(items.fee3));
                        $("#mdltoday_sale4").text("￥ "+fee2num(items.fee4));
                        $("#mdltoday_num1").text(items.num1);
                        $("#mdltoday_num2").text(items.num2);
                        var paylist=result.paytypelist;
                        $(".mdltoday_salepay").each(function(){
                            var index=parseInt($(this).attr("id").replace("mdltoday_salepay",""));
                            var temp= paylist[index]!=null ? fee2num(paylist[index].fee1): "0" ;
                            if(refundlist[index]!=null){
                                temp+=" - ";
                                temp+=refundlist[index]!=null ? fee2num(refundlist[index]) : "0";
                                temp+= "="+fee2num(parseInt(paylist[index].fee1)-parseInt(refundlist[index]));
                            }
                            $(this).text("￥ "+temp);
                        });
                        var chargeitem=result.chargeitems;
                        $("#mdltoday_charge").text("("+chargeitem.num1+") ￥ "+fee2num(chargeitem.fee1));
                        var chargelist=result.chargelist;
                        $("#mdltoday_chargepay0").text("￥ "+(chargelist[0]!=null ? fee2num(parseInt(chargelist[0])) : "-"));
                        $("#mdltoday_chargepay1").text("￥ "+(chargelist[1]!=null ? fee2num(parseInt(chargelist[1])) : "-"));
                        $("#mdltoday_chargepay2").text("￥ "+(chargelist[2]!=null ? fee2num(parseInt(chargelist[2])) : "-"));
                        $("#mdltoday_chargepay3").text("￥ "+(chargelist[3]!=null ? fee2num(parseInt(chargelist[3])) : "-"));
                        var allcash=(chargelist[2]!=null ? parseInt(chargelist[2]) : 0) + (paylist[2]!=null ? parseInt(paylist[2].fee1) : 0);
                        $("#mdltoday_allcash").text("￥" + fee2num(allcash-parseInt(refundlist[2])));
                        var allfee=(items.fee3!=null ? parseInt(items.fee3) : 0)+(chargeitem.fee1!=null ? parseInt(chargeitem.fee1):0);
                        $("#mdltoday_all").html("<b>￥ "+fee2num(allfee-parseInt(refundorder.fee1)-parseInt(refundgoods.fee1))+"</b>");
                        $("#mdltoday_refundfee").text("￥" + fee2num(parseInt(refundorder.fee1)+parseInt(refundgoods.fee1)));
                        $("#mdltoday_refundorder").text(refundorder.num1);
                        $("#mdltoday_refundgoods").text((parseInt(refundorder.num2)+parseInt(refundgoods.num1)));
                    }else{
                        layer.msg(result.msg,{icon:2,time:1500});
                        return;
                    }
                });
            },
            end:function(){
                $(".modal_today").hide();
                $(".modal_todaysubmit").unbind("click");
                $(".modal_todayboxclose").unbind("click");
            }
        });
    }
    function funSys_todaygoods(){
        layer.open({
            type: 1,
            title:"今日商品销售",
            area:"700px",
            skin: 'layui-layer-rim',
            content:$(".modal_todaygoods").show(),
            success: function(layero, index){
                $(".modal_todaygoodsboxclose").on("click",function(){
                    layer.close(index);
                });
                $(".modal_todaygoodssubmit").on("click",function(){
                    fun_print(11,0);
                });
                var index2=layer.load(1, {shade: [0.1,'#fff']});
                $.post("{php echo $this->createMobileUrl('index',array('op'=>'gettodaygoods'))}",{},function(returnstr){
                    layer.close(index2);
                    console.log(returnstr);
                    var result=eval("("+returnstr+")");
                    if(result.success){
                        var list=result.list;
                        $(".modal_todaygoods tbody").empty();
                        for(var i in list){
                            var fee=parseFloat(list[i].price2)*100*parseInt(list[i].num1);
                            var temp='<tr><td>'+list[i].title2+'</td><td>'+list[i].sn+'</td><td>￥'+(parseFloat(list[i].price2)).toFixed(2)+'</td><td>'+list[i].num1+'</td><td>￥'+fee2num(fee)+'</td><td>￥'+fee2num(list[i].fee1)+'</td></tr>';
                            $(".modal_todaygoods tbody").append(temp);
                        }
                    }else{
                        layer.msg(result.msg,{icon:2,time:1500});
                        return;
                    }
                });
            },
            end:function(){
                $(".modal_todaygoods").hide();
                $(".modal_todaygoodsboxclose").unbind("click");
                $(".modal_todaygoodssubmit").unbind("click");
            }
        });
    }
    $(document).ready(function(){
        rootColock();
        setInterval("rootColock()",60000)
    });
    function rootColock(){
        var now=new Date();
        var month=now.getMonth()+1;
        var day=now.getDate();
        var hours=now.getHours();
        var minutes=now.getMinutes();
        var seconds=now.getSeconds();
        $("#root_timer").text(month+"-"+day+" "+hours+":"+minutes);
    }
</script>